﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Reflection;
using System.IO;

namespace Triples.Model {
    public class BoardSeeds {

        public static Random Rand = new Random();
        //public static int NextIndex = 0;
        //public static string Resource = ;

        public static int GenerateSeed() {
            Random r = new Random();
            Assembly assembly = Assembly.GetExecutingAssembly();
            byte[] seedBytes = new byte[sizeof(int)];

            using (Stream stream = assembly.GetManifestResourceStream("Triples.Resources.seeds.bin")) {

                using (BinaryReader byteReader = new BinaryReader(stream)) {
//                    int seedIndex = NextIndex++;
                    int seedIndex = r.Next(0, Convert.ToInt32(stream.Length) / sizeof(int));
                    int seekByte = sizeof(int) * seedIndex;

                    byteReader.BaseStream.Seek(seekByte, SeekOrigin.Begin);
                    byteReader.Read(seedBytes, 0, sizeof(int));
                }

                stream.Close();
            }

            return BitConverter.ToInt32 (seedBytes, 0);
        }
    }
}
